package com.hydl.power.controller;

import com.hydl.power.pojo.HomeData;
import com.hydl.power.pojo.Identical;
import com.hydl.power.pojo.PowerRoom;
import com.hydl.power.service.HomeService;
import com.hydl.power.utils.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;


@Api(value = "HomeController",tags = "看板")
@RequestMapping("/home")
@RestController
@CrossOrigin
public class HomeController {

    @Autowired
    private HomeService homeService;


    @ApiOperation(value = "配电房模糊查询", produces = "application/json")
    @PostMapping("getPowerRoom")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roomName", value = "配电房名字",  dataType = "String",defaultValue = "配电房"),
    })
    public Resp getPowerRoom(String roomName) {
        List<PowerRoom> list=homeService.getPowerRoom(roomName);
        return Resp.success(list);
    }



    @ApiOperation(value = "电能分析/告警分析", produces = "application/json")
    // @LogAnnotation(module = "看板",description = "电能分析/告警分析")
    @PostMapping("getPowerData")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roomId", value = "配电房id",required = true,  dataType = "String"),
    })
    public Resp getPowerData(String roomId ) throws ParseException {
        HomeData homeData= homeService.getPowerData(roomId);

        return Resp.success(homeData);
    }


    @ApiOperation(value = "配电房配置", produces = "application/json")
    // @LogAnnotation(module = "看板",description = "项目配置")
    @PostMapping("getPowerRoomData")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roomId", value = "配电房id",required = true,  dataType = "String"),
    })
    public Resp getPowerRoomData(String roomId) {
        List<String> list=homeService.getPowerRoomData(roomId);
        return Resp.success(list);
    }


    @ApiOperation(value = "负载分析", produces = "application/json")
    //  @LogAnnotation(module = "看板",description = "负载分析")
    @PostMapping("getLoadData")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "roomId", value = "配电房id",required = true,  dataType = "String",defaultValue = "56149022"),
    })
    public Resp getLoadData(String roomId) {
        List<List<String>> list=homeService.getLoadData(roomId);
        return Resp.success(list);
    }

    @ApiOperation(value = "日同比分析", produces = "application/json")
    @PostMapping("queryYearOnYearDays")
    @ApiImplicitParams({
      @ApiImplicitParam(paramType = "query", name = "roomId", value = "配电房id",required = true,  dataType = "String",defaultValue = "56149022"),
    })
    public Resp queryYearOnYearDays(String roomId) {
      List<Identical> list=homeService.queryYearOnYearDays(roomId);
      return Resp.success(list);
    }



}
